import Vue from "vue";
import AppComponent from "./App/App.vue";
import hotReload from "@/utils/hotReload";
import Storage from 'vue-ls'
import store from '@/store'
import {USER_ACCOUNT,USER_PROFILE,USER_COOKIE} from "@/store/mutation-types";
import router from "@/router";
import {MUSIC_PLAY_LIST} from "@/store/mutation-types";

Vue.component("app-component", AppComponent);
// 打包后自动刷新
hotReload();

// import Antd from 'ant-design-vue'
// import 'ant-design-vue/dist/antd.less';
// Vue.use(Antd)
// 按需加载
import {Row,Col,Layout,Icon,Modal,Tabs,message,Menu,Table,Carousel,Button} from 'ant-design-vue'
Vue.use(Row)
Vue.use(Col)
Vue.use(Layout)
Vue.use(Layout.Header)
Vue.use(Layout.Content)
Vue.use(Layout.Footer)
Vue.use(Layout.Sider)
Vue.use(Modal)
Vue.use(Icon)
Vue.use(Tabs)
Vue.use(Tabs.TabPane)
Vue.use(Menu)
Vue.use(Menu.Item)
Vue.use(Menu.ItemGroup)
Vue.use(Table)
Vue.use(Carousel)
Vue.use(Button)
Vue.prototype.$message = message;

Vue.use(Storage)
// Vue.prototype.$bg = chrome.extension.getBackgroundPage();
// 参考网址 https://www.thinbug.com/q/15052507
// let bg = chrome.extension.getBackgroundPage() ;
// console.log(bg.audio)
// console.log(chrome.extension.getViews())
// console.log(chrome.extension.getBackgroundPage().audio)
let bg = chrome.extension.getBackgroundPage();
// 设置默认音量
bg.musicPlayer.context.volume = 0.2;
bg.musicPlayer.musicList = Vue.ls.get(MUSIC_PLAY_LIST)
// Vue.prototype.$bg =bg;
// Vue.prototype.$audio = window.zwAudio;

// 注册eventbus
Vue.prototype.$eventBus = new Vue();

new Vue({
  el: "#app",
  router,
  store,
  mounted() {
    store.commit('SET_ACCOUNT',Vue.ls.get(USER_ACCOUNT))
    store.commit('SET_PROFILE',Vue.ls.get(USER_PROFILE))
    store.commit('SET_COOKIE',Vue.ls.get(USER_COOKIE))
    Vue.prototype.$bg =bg;
  },
  render: createElement => {
    return createElement(AppComponent);
  }
});
